package easy;

public class ClimbingStairs {
    //超时
    public int climbStairs0(int n) {
        if(n==1) return 1;
        if(n==2) return 2;
        return climbStairs0(n-1) + climbStairs0(n-2);

    }

    public int climbStairs(int n){
        if(n<0) return 0;
        if(n==1) return 1;
        int pre = 1;
        int cur = 2;
        for(int i=2;i<n;i++){
            int temp = cur;
            cur = cur + pre;
            pre = temp;
        }
        return cur;
    }

}
